//随机发牌程序的实现
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

//定义一个二维数组记录发过的牌
int piece[4][13] = {0};

int main(void){
		//1.设置随机种子
		srand(time(0));
		//4.定义两个变量保存玩家人数以及每个玩家的牌数
		int player = 0,card = 0;
		printf("请输入玩家人数以及每个玩家的牌数\n");
		scanf("%d%d",&player,&card);
		//6.进行错误判断
		if(player < 0 || card < 0 || player*card >52){
				printf("输入不正确，玩笑开的太大了吧\n");
				return -1;
				}
		int i = 0,j = 0;
		for(i = 0;i < player;i++){
				printf("第%d个玩家的牌是：",i+1);
				for(j = 0;j < card;j++){
						//2.随机生成牌的花色和点数并且输出
						int color = rand() % 4;
						int point = rand() % 13;
						//printf("随机生成的扑克是：")
						//5.判断新判断的牌是否重复
						if(0 == piece[color][point]){
								piece[color][point] = -1; //记录发过的牌
								}
						else{
								j--;
								continue;
								}
						//3.获得的整数数值转换为字符串
						switch(color){
								case 0:printf("黑桃");break;
								case 1:printf("红桃");break;
								case 2:printf("梅花");break;
								case 3:printf("方片");break;
								}
						switch(point + 1){
								case 1:printf("A ");break;
								case 11:printf("J ");break;
								case 12:printf("Q ");break;
								case 13:printf("K ");break;
								default:printf("%d ",point +1);
								}
						}
						printf("\n");
				}
			return 0;
		}
